[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
WHILE (BEXP) statement ...
-or-
WHILE (BEXP) DO
statement(s)
ENDWHILE
Function
Execute one or more statments while a condition is true.
Syntax
WHILE (BEXP) statement
-or-
WHILE (BEXP) DO
statement(s)
ENDWHILE
BEXP - Any boolean expression.
statement - Any valid PPL statement.
Remarks
Computers are known for their ability to perform monotonous tasks
quickly, efficiently, and accurately. What better way to implement
monotony than through a WHILE loop? The WHILE statement supports two
types of loops: logical and block. A logical WHILE loop is a single
statement; if a condition is TRUE, execute a single statement and check
again. A block WHILE loop can be one or more statements. The start of a
block WHILE loop is differentiated from a logical WHILE loop by the DO
keyword immediately after the condition. At some point in the loop some
action must be taken that will make the condition FALSE. If the
condition never changes from TRUE to FALSE you have what is known as an
infinite loop; your computer will appear to be hung, even though it is
rapidly executing things just as fast as it can. Be sure to thoroughly
test all programs, but especially programs with loops!
Examples
INTEGER i
LET i = 0
WHILE (i < 10) GOSUB sub
END
:sub
PRINTLN "i is ",i
INC i
RETURN
INTEGER i
LET i = 0
WHILE (i < 10) DO
PRINTLN "i is ",i
INC i
ENDWHILE
See Also:
FOR/NEXT
IF/ELSE(IF)/ENDIF
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson